using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using PickGold.Charting;

namespace PickGold.Charting.ChartTypes
{
	internal class PolarChart : RadarChart
	{
		protected override RadarDrawingStyle GetDrawingStyle(Series ser, DataPoint point)
		{
			RadarDrawingStyle line = RadarDrawingStyle.Line;
			if (!point.IsCustomPropertySet("PolarDrawingStyle") && !ser.IsCustomPropertySet("PolarDrawingStyle"))
			{
				return line;
			}
			string strA = point.IsCustomPropertySet("PolarDrawingStyle") ? point["PolarDrawingStyle"] : ser["PolarDrawingStyle"];
			if (string.Compare(strA, "Line", StringComparison.OrdinalIgnoreCase) == 0)
			{
				return RadarDrawingStyle.Line;
			}
			if (string.Compare(strA, "Marker", StringComparison.OrdinalIgnoreCase) != 0)
			{
				throw new InvalidOperationException(SR.ExceptionCustomAttributeValueInvalid(strA, "PolarDrawingStyle"));
			}
			return RadarDrawingStyle.Marker;
		}

		public override int GetNumerOfSectors(ChartArea area, SeriesCollection seriesCollection)
		{
			int num = 12;
			double interval = area.AxisX.Interval;
			if (area.AxisX.LabelStyle.GetInterval() > 0.0)
			{
				interval = area.AxisX.LabelStyle.GetInterval();
			}
			if (interval != 0.0)
			{
				double num3 = area.AxisX.AutoMaximum ? 360.0 : area.AxisX.Maximum;
				double num4 = area.AxisX.AutoMinimum ? 0.0 : area.AxisX.Minimum;
				num = (int)(Math.Abs((double)(num3 - num4)) / interval);
			}
			return num;
		}

		protected override PointF[] GetPointsPosition(ChartGraphics graph, ChartArea area, Series series)
		{
			PointF[] tfArray = new PointF[series.Points.Count + 1];
			int pointIndex = 0;
			foreach (DataPoint point in series.Points)
			{
				double axisValue = this.GetYValue(base.Common, area, series, point, pointIndex, 0);
				double position = area.AxisY.GetPosition(axisValue);
				double x = area.circularCenter.X;
				tfArray[pointIndex] = graph.GetAbsolutePoint(new PointF((float)x, (float)position));
				float angle = area.CircularPositionToAngle(point.XValue);
				Matrix matrix = new Matrix();
				matrix.RotateAt(angle, graph.GetAbsolutePoint(area.circularCenter));
				PointF[] pts = new PointF[] { tfArray[pointIndex] };
				matrix.TransformPoints(pts);
				tfArray[pointIndex] = pts[0];
				pointIndex++;
			}
			tfArray[pointIndex] = graph.GetAbsolutePoint(area.circularCenter);
			return tfArray;
		}

		public override float[] GetYAxisLocations(ChartArea area)
		{
			float[] numArray = new float[] { 0f };
			if (!double.IsNaN(area.AxisX.Crossing))
			{
				numArray[0] = (float)area.AxisX.Crossing;
				while (numArray[0] < 0f)
				{
					numArray[0] = 360f + numArray[0];
				}
			}
			return numArray;
		}

		public override bool RadialGridLinesSupported()
		{
			return true;
		}

		public override bool RequireClosedFigure()
		{
			return false;
		}

		public override bool XAxisCrossingSupported()
		{
			return true;
		}

		public override bool XAxisLabelsSupported()
		{
			return true;
		}

		public override string Name
		{
			get
			{
				return "Polar";
			}
		}
	}
}

